package banmuoi.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;

import banmuoi.util.WebUtil;

public class SecurityAction extends HttpServlet{
	
	static String checkLogin(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
		Cookie[] cookies = req.getCookies();
		String name = "";
		String value = "";
		for(int i=0; cookies != null && i<cookies.length; i++){
			Cookie cookie = cookies[i];
			name = cookie.getName();	
			value = cookie.getValue();//idPermission
			if(name.equals("isAdmin")){			
				break;
			}				
		}
		
		if(name.equals("isAdmin")){
			return value;
		}
			
		else {
			return null;
		}
	}

}
